/**
 * 
 */
package com.easidea.tim.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import net.digitalprimates.persistence.hibernate.proxy.HibernateProxy;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.springside.core.dao.extend.UndeletableEntity;

/**
 * Base entity for JPA, every entity should extends with this class
 * 
 * @author Harrison
 *
 */
@MappedSuperclass
public class BaseEntity extends HibernateProxy  implements UndeletableEntity, Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 4131005697505278614L;
	protected Long id;
	private Date createTime = new Date();
	private Date modifyTime = new Date();
	private String creator;
	private String modifier;
	private Short deleted = 0;

	
	public BaseEntity() {
		super();
	}

	@Basic
	public String getCreator() {
		return creator;
	}

	public void setCreator(String creator) {
		this.creator = creator;
	}

	@Basic
	@Column(name = "create_time")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Basic
	@Column(name = "modified_time")
	@Temporal(TemporalType.TIMESTAMP) 
	public Date getModifyTime() {
		return modifyTime;
	}

	public void setModifyTime(Date modifyTime) {
		this.modifyTime = modifyTime;
	}

	@Basic
	public String getModifier() {
		return modifier;
	}

	public void setModifier(String modifier) {
		this.modifier = modifier;
	}
	
	/**
	 * @return the deleted
	 */
	@Basic
	@Column(name = "deleted")
	public Short getDeleted() {
		return deleted;
	}

	public void setDeleted(Short deleted) {
		this.deleted = deleted;
	}
	
	@Override
	public String toString(){
		return ToStringBuilder.reflectionToString(this);
	}
	
	@Override
	public boolean equals(Object obj) {
		return EqualsBuilder.reflectionEquals(obj, this);
	}

	/**
	 * @return the id
	 */
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}
}
